# 这里举例：http://sahitest.com/demo/selectTest.htm
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.select import Select        # 导入Select控件
# 实例化驱动
driver = webdriver.Chrome()
# 打开网页
driver.get('http://sahitest.com/demo/selectTest.htm')
# 全屏化
driver.maximize_window()
#定位到第一个下拉框
select_s1Id = WebDriverWait(driver,10,0.5).until(EC.presence_of_element_located((By.ID,'s1Id')))
# 实例化Select控件
s1 = Select(select_s1Id)

# 通过手动输入文本内容选择
# s1.select_by_visible_text('o3')

# 通过value内容选择
# s1.select_by_value('o2')

# 通过索引来进行选择
s1.select_by_index(1)

# 等待
time.sleep(8)